/**
* @author gaon0331
*/

package controls{
	import flash.display.MovieClip;
	import controls.Button;
	import flash.events.Event;
	
	public class ButtonBar {
				
		private var _target:MovieClip;
		
		private var _render:Class;
		private var _direction:String;
		private var _spacing:Number = 0;
		
		public var _button:Button;
		public var _btnAry:Array;
		
		
		public function ButtonBar($target:MovieClip = null)
		{
			if ($target != null)
			{
				trace("Button Class 타겟  완료");
				target = $target;
			}
		}
		
		public function dataProvider($data:Object):void{
			
			var mc:MovieClip;
			var dataLength:int = $data.length;
			
			trace("dataLength = " + String(dataLength));
			
			_btnAry = [];
			
			for(var i:int = 0; i<dataLength; i++)
			{
				mc = new _render();
				
				_target.addChild(mc);
				_btnAry[i] = mc;
				
				_button = mc as Button;
				//_button.addEventListener( Button.CLICK, onClickHandler);
			}
			
			range();
		}
		
		private function range():void
		{
			var listlength:int = _btnAry.length;
			var mc:MovieClip;
			
//			var targetX:Number = 0;
			var targetY:Number = 0;
			
			for(var i:int = 0; i< listlength; i++)
			{
				mc = _btnAry[i];
				
				mc.y = targetY;
				targetY += mc.hit.height+ _spacing;
			}
		}
		
		public function get render():Class {return _render;}
		public function set render( $render : Class ):void
		{
			_render = $render;
		}
		
		public function get direction():String { return _direction; }
		public function set direction($direction:String):void
		{
			_direction = $direction;
		}
		
		public function get spacing():Number { return _spacing; }
		public function set spacing($spacing:Number):void
		{
			_spacing = $spacing;
		}
		
		public function get target() : MovieClip { return _target; }
		public function set target( $target:MovieClip ) : void 
		{
			_target = $target;
		}
		
		private function onClickHandler( $e : Event ) : void 
		{
			
		}
	}
}
